package com.authority.basic.general_basic.listener;

import com.authority.basic.general_basic.entiy.MyCustomEvent;
import com.authority.basic.general_basic.entiy.User;
import org.springframework.context.ApplicationListener;
import org.springframework.stereotype.Component;

@Component
public class MyListener implements ApplicationListener<MyCustomEvent> {// 范型是监听的事件

    @Override
    public void onApplicationEvent(MyCustomEvent event) {

        System.out.println("我监听到该事件：" +event.getMsg());
        User user= (User) event.getSource();
        System.out.println(user.toString());

    }
}
